package com.example.com.daervideo.fragments;

import android.content.Intent;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.example.com.daervideo.BR;
import com.example.com.daervideo.R;
import com.example.com.daervideo.activitys.MainActivity;
import com.example.com.daervideo.activitys.StrategyActivity;
import com.example.com.daervideo.activitys.users.WalletActivity;
import com.example.com.daervideo.databinding.FragemntCollectionBinding;
import com.example.com.daervideo.entity.WaterBallBean;
import com.example.com.daervideo.myViews.CollectView;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.base.BaseFragment;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.bus.RxBus;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class CollectionFragmrnt extends BaseFragment<FragemntCollectionBinding, BaseViewModel> implements CollectView.OnStopAnimateListener, View.OnClickListener {


    @Override
    public int initContentView() {
        return R.layout.fragemnt_collection;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public BaseViewModel initViewModel() {
        return new BaseViewModel(context);
    }

    @Override
    public void initData() {
        super.initData();

        setlistener();
    }

    private void setlistener() {
        binding.collectView.setOnStopAnimateListener(CollectionFragmrnt.this);
        binding.back.setOnClickListener(this);
        binding.getStrategy.setOnClickListener(this);
        binding.gemTask.setOnClickListener(this);
        binding.getMoney.setOnClickListener(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        binding.cl.postDelayed(new Runnable() {
            @Override
            public void run() {
                final List<WaterBallBean> waterBallBeanList = new ArrayList<>();
                WaterBallBean waterBallBean = null;
                int size = 10;
                for (int i = 0; i < size; i++) {
                    waterBallBean = new WaterBallBean("" + i, "哈哈", i + "", false);
                    waterBallBeanList.add(waterBallBean);
                }
                binding.collectView.setData(waterBallBeanList);

            }
        }, 2000);
    }

    @Override
    public void onBallDisappearAnimListener(String number) {
        ToastUtils.showShort("AnimEnd");
    }

    @Override
    public void onExitAnimateListener() {
        ToastUtils.showShort("destroy");
    }

    private void startAssetTextAnimStep1(String number) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back:
                RxBus.getDefault().post(1);
                break;
            case R.id.get_strategy:
                Intent intent = new Intent(context, StrategyActivity.class);
                startActivity(intent);
                break;
            case R.id.gem_task:
                ToastUtils.showShort("任务");
                break;
            case R.id.get_money:
                startActivity(new Intent(context, WalletActivity.class));
                break;
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        binding.collectView.clear();
    }
}
